package com.sl.mes.db.service.pd;

import com.sl.mes.db.dao.PdWkMapper;
import com.sl.mes.db.itf.pd.IPdWk;
import com.sl.mes.db.vo.PdWk;
import com.sl.mes.db.vo.PdWkExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PdWkService implements IPdWk {
    @Resource
    private PdWkMapper pdWkMapper;

    /**
     * 根据	cpdwkid查工作中心生产档案
     * @param cpdwkid
     * @return
     */
    @Override
    public PdWk findById(String cpdwkid) {
        return pdWkMapper.selectByPrimaryKey(cpdwkid);
    }

    /**
     * 根据批次查询
     * @param vdef3
     * @return
     */
    @Override
    public PdWk findByVdef3(String vdef3) {
        PdWkExample example=new PdWkExample();
        example.or().andVdef3EqualTo(vdef3).andDrEqualTo(0);
        PdWk pdWk = pdWkMapper.selectOneByExample(example);
        return pdWk;
    }

    @Override
    public List<PdWk> repeatWQuery() {
        PdWkExample pdWkExample=new PdWkExample();
        return pdWkMapper.selectByExample(pdWkExample);
    }

    @Override
    public PdWk findByCwkid(String cwkid) {
        PdWkExample pdWkExample=new PdWkExample();
        pdWkExample.or().andCwkidEqualTo(cwkid).andDrEqualTo(0);
        PdWk pdWk = pdWkMapper.selectOneByExample(pdWkExample);
        return pdWk;
    }

}
